package com.gp.billsrecord.ui.main.adapters

import android.view.LayoutInflater
import android.view.ViewGroup
import com.gp.billsrecord.base.BaseRecyclerViewAdapter
import com.gp.billsrecord.databinding.ItemBarChartBinding
import com.gp.billsrecord.extensions.toMoney
import com.gp.billsrecord.model.data.BarChartInfo

class BarChartAdapter : BaseRecyclerViewAdapter<BarChartInfo, ItemBarChartBinding>() {
    override fun onCreateBinding(
        inflater: LayoutInflater,
        parent: ViewGroup,
        viewType: Int
    ): ItemBarChartBinding = ItemBarChartBinding.inflate(inflater, parent, false)

    override fun onBind(data: BarChartInfo, binding: ItemBarChartBinding) {
        binding.progressBarProgress.progress = data.progress
        binding.tvBarProgress.text = "${data.progress}%"
        binding.tvBarTypeName.text = data.typeName
        binding.tvBarBalance.text = "¥ ${data.balance.toMoney()}"
    }
}
